<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="gp" uri="http://gp.componentesx"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>



<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Datepicker</title> 

<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/resources/componentes/importacoes/jquery-ui-1.11.4.custom/jquery-ui.css"/>
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/resources/componentes/importacoes/jquery-ui-1.11.4.custom/jquery-ui.theme.css"/>
<link type="text/css" rel="stylesheet" href="${pageContext.request.contextPath}/resources/componentes/importacoes/jquery-ui-1.11.4.custom/jquery-ui.theme.min.css"/>
<script src="${pageContext.request.contextPath}/resources/componentes/importacoes/jquery-ui-1.11.4.custom/external/jquery/jquery-1.10.2.js"></script>
<script src="${pageContext.request.contextPath}/resources/componentes/importacoes/jquery-ui-1.11.4.custom/jquery-ui.js"></script>


</head>
<body>

<label for="${labelFor}">${labelText}</label>
<input class="${inputClass}"  type="text" name="${inputName}" id="${idDatepicker}"/>


<script type="text/javascript" src="${pageContext.request.contextPath}/resources/componentes/calendario/js/Datepicker.js"></script>
<script type="text/javascript">

	var dp = new Datepicker();
	var json = "";	
	//var idDatepicker = "${idDatepicker}";
	//var seletor = "${form}";
	var seletor = "#" + "${form}" + " " + "#" + "${idDatepicker}";

	<c:if test = "${not empty showOn}">
	
		json = $.extend(json,{"showOn": "${showOn}"}); 
		
	</c:if>

	<c:if test = "${not empty onClose}">

		var onClose = "${onClose}";
		json = $.extend(json,{"onClose": 

			function(dateText, inst){
				
	 	 	 	alert(onClose + dateText);

	 	 	}
 	 	
	    });
	
	</c:if>
	
	<c:if test = "${not empty showOtherMonths}">

		json = $.extend(json,{"showOtherMonths": "${showOtherMonths}"});

	</c:if>

	<c:if test = "${not empty changeYear}">

		json = $.extend(json,{"changeYear": "${changeYear}"});

	</c:if>

	<c:if test = "${not empty changeMonth}">

		json = $.extend(json,{"changeMonth": "${changeMonth}"});

	</c:if>

	<c:if test = "${not empty showAnim}">

		json = $.extend(json,{"showAnim": "${showAnim}"});

	</c:if>

	<c:if test = "${not empty beforeShowDay}">

		<c:if test = "${beforeShowDay eq 'noWeekends'}">
	
			json = $.extend(json,{"beforeShowDay": $.datepicker.noWeekends});

		</c:if>

	</c:if>

	//Usuário passa o teto direto no appendText="texto"
	<c:if test = "${not empty appendText}">

		json = $.extend(json,{"appendText": "${appendText}"});

	</c:if>

	<c:if test = "${not empty hideIfNoPrevNext}">
						                             
		json = $.extend(json,{"hideIfNoPrevNext": "${hideIfNoPrevNext}"});
			
	</c:if>

	//Valor pode ser passado diretamente na chamada do atributo, maxDate="+1w"
	<c:if test = "${not empty maxDate}">

		json = $.extend(json,{"maxDate": "${maxDate}"});

	</c:if>

	//Valor pode ser passado diretamente na chamada do atributo, dateFormat="yy/mm/dd"
	<c:if test = "${not empty dateFormat}">

		json = $.extend(json,{"dateFormat": "${dateFormat}"});

	</c:if>

	//dayNames="Chi,Fri,Cna,Hud,Tir,Frd,saa"
	<c:if test = "${not empty dayNames}">
	
		var dayNames = "${dayNames}";
		var vetDayNames = dayNames.split(",");
		json = $.extend(json,{"dayNames": vetDayNames});

	</c:if>

	//dayNamesMin="Chi,Fri,Cna,Hud,Tir,Frd,saa"
	<c:if test = "${not empty dayNamesMin}">
		var dayNamesMin = "${dayNamesMin}";
		var vetDayNamesMin = dayNamesMin.split(",");
		json = $.extend(json,{"dayNamesMin": vetDayNamesMin});

	</c:if>

	//monthNames="Chi,Fri,Cna,Hud,Tir,Frd,saa"
	<c:if test = "${not empty monthNames}">
		var monthNames = "${monthNames}";
		var vetMonthNames = monthNames.split(",");
		json = $.extend(json,{"monthNames": vetMonthNames});

	</c:if>

	//monthNamesShort="Chi,Fri,Cna,Hud,Tir,Frd,saa"
	<c:if test = "${not empty monthNamesShort}">

		var monthNamesShort = "${monthNamesShort}";
		var vetMonthNamesShort = monthNamesShort.split(",");
		json = $.extend(json,{"monthNamesShort": vetMonthNamesShort});

	</c:if>

	//dp.criarCalendario("#" + seletor + " " + "#" + idDatepicker, json);
	dp.criarCalendario(seletor, json);

	//Método setDate	
	<c:if test = "${not empty setDate}">

		<c:if test = "${setDate eq 'true'}">

			//dp.setDate("#" + seletor + " " + "#" + idDatepicker);
			dp.setDate(seletor);
		
		</c:if>
	
	</c:if>
	

	
	
	
</script>

</body>
</html>